﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MethodWorx.CMS.Providers;
using StructureMap;
using MethodWorx.Core.DomainModel;

namespace MethodWorx.CMS.UI.Application.Dependencies
{
    public class StructureMapCmsDataProvider : ICmsDataProvider
    {
        public void Initialize()
        {
            
        }

        public T GetService<T>()
        {
            return ObjectFactory.GetInstance<T>();
        }

        public IUnitOfWorkFactory GetUnitOfWorkFactory()
        {
            return ObjectFactory.GetInstance<IUnitOfWorkFactory>();
        }

        public IRepositoryRegistry GetRepositoryRegistry()
        {
            return new StructureMapRepositoryRegistry();
        }


        public void AddService<TInterface, TConcrete>() where TConcrete : TInterface
        {
            ObjectFactory.Configure(c => c.For<TInterface>().Use<TConcrete>());
        }
    }
}